from django.urls import path
from .views.note_views import NoteListView, CreateNoteView, NoteDetailView, TagListView, TagDetailView, \
    CategoryListView, CategoryDetailView, NoteTagListView, NoteCategoryListView, NoteSearchView
from .views.ai_views import NoteSummaryView, NoteChatView, NotePlanView, OptimizeContentView as NoteOptimizeContentView
from .views.fine_tuning_views import FineTuningNoteOptimizationView
from .views.voice_views import VoiceRecognitionView
from .views.ocr_views import OCRRecognitionView, NoteOCRRecognitionView, TableRecognitionView
from .views.schedule_views import extract_schedules_from_note, get_note_related_schedules, create_schedules_from_note
from .views.pdf_views import PDFExportView, PDFTemplatesView


# 用户相关视图路由
urlpatterns = [
    # 搜索路由必须放在其他笔记路由之前
    path('notes/search/', NoteSearchView.as_view(), name='note-search'),
    
    # 基础笔记路由
    path('notes/', NoteListView.as_view(), name='note-list'),
    path('notes/create/', CreateNoteView.as_view(), name='create-note'),
    path('notes/<int:pk>/', NoteDetailView.as_view(), name='note-detail'),

    # 标签相关视图路由
    path('tags/', TagListView.as_view(), name='tag-list'),
    path('tags/<int:pk>/', TagDetailView.as_view(), name='tag-detail'),

    # 分类相关视图路由
    path('categories/', CategoryListView.as_view(), name='category-list'),
    path('categories/<int:pk>/', CategoryDetailView.as_view(), name='category-detail'),

    # 笔记标签关联视图路由
    path('note-tags/', NoteTagListView.as_view(), name='note-tag-list'),

    # 笔记分类关联视图路由
    path('note-categories/', NoteCategoryListView.as_view(), name='note-category-list'),

    # 对话AI功能路由
    path('notes/chat/', NoteChatView.as_view(), name='note-chat'),  # 统一使用一个路由，通过请求体传递note_id
    path('notes/<int:pk>/summary/', NoteSummaryView.as_view(), name='note-summary'),
    path('notes/<int:pk>/plan/', NotePlanView.as_view(), name='note-plan'),
    path('notes/<int:pk>/optimize/', NoteOptimizeContentView.as_view(), name='optimize-content'),

    # 语音和文本扫描等其他路由
    path('voice/recognize/', VoiceRecognitionView.as_view(), name='voice-recognize'),
    path('ocr/recognize/', OCRRecognitionView.as_view(), name='ocr-recognize'),
    path('ocr/table/recognize/', TableRecognitionView.as_view(), name='table-recognize'),

    # 笔记生成日程相关路由
    path('notes/<int:note_id>/extract-schedules/', extract_schedules_from_note, name='extract-schedules-from-note'),
    path('notes/<int:note_id>/create-schedules/', create_schedules_from_note, name='create-schedules-from-note'),
    path('notes/<int:note_id>/related-schedules/', get_note_related_schedules, name='get-note-related-schedules'),
    
    # 新增微调模型笔记优化服务
    path('ai/optimize/fine-tuning/', FineTuningNoteOptimizationView.as_view(), name='optimize-ai-fine-tuning'),
    
    # PDF相关路由
    path('pdf/to-markdown/', NoteOCRRecognitionView.as_view(), name='pdf-to-markdown'),
    path('pdf/export/', PDFExportView.as_view(), name='pdf-export'),
    path('pdf/templates/', PDFTemplatesView.as_view(), name='pdf-templates'),
]
